exports.install = function (Vue, options) {
  Vue.prototype.deleteLimitedHistory = function () {
    // 定义变量
    var historyKeyRecord = []
    var historyCount = 0
    // 定义比较函数
    function compare (property) {
      return function (a, b) {
        var value1 = a[property]
        var value2 = b[property]
        return value1 - value2
      }
    }
    // 获取本地存储的记录，并根据时间排序
    for (let i = 0; i < localStorage.length; i++) {
      var startIndex = localStorage.key(i).indexOf('E-20')
      if (startIndex === 0) {
        historyCount += 1
        var keyString = localStorage.key(i).substring(2)
        var moment = require('moment')
        historyKeyRecord.push({'key': 'E-' + keyString, 'date_time': moment(keyString, 'YYYY/MM/DD/hh:mm:ss').format('X')})
        historyKeyRecord.sort(compare('date_time'))
        console.log('FunctionName:deleteLimitedHistory,Action:Sort Record is OK')
      }
    }

    // 如果计数大于指定数，则将晚一些的记录删除
    if (historyCount > this.$store.state.MAX_HISTORY_COUNT) {
      var limitOut = historyCount - this.$store.state.MAX_HISTORY_COUNT
      for (var i = 0; i < limitOut; i++) {
        var key = historyKeyRecord[i].key
        // console.log(key)
        localStorage.removeItem(key)
        console.log('FunctionName:deleteLimitedHistory,Action:Record was deleted OK')
      }
      console.log('FunctionName:deleteLimitedHistory,Action:No Record can be delete')
    }
  }
}
